package com.diankangwo.service.impl;

import com.diankangwo.dao.PayManagementDAO;
import com.diankangwo.domain.PayManagement;
import com.diankangwo.service.PayManagementService;
import com.diankangwo.util.PageSupport;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.Serializable;
import java.util.List;

/***
 * @author songrongye payManagementService的实现类
 */
@Service(value = "payManagementService")
public class PayManagementServiceImpl implements PayManagementService {

	@Autowired
	private PayManagementDAO pmd;

	/***
	 *            t 缴费信息的增加和修改
	 */
	@Override
	public void saveOrUpdate(PayManagement t) {
		try {
			pmd.saveOrUpdate(t);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	/***
	 * 根据ID删除缴费信息
	 */
	public boolean deleteById(int id) {
		if (id != 0) {
			pmd.deleteById(id);
			return true;
		} else {
			return false;
		}
	}

	/***
	 * 分页查找缴费信息
	 */

	public List<PayManagement> findPage(int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return pmd.findList(pageNo, pageSize);
	}

	/***
	 * 根据ID查找缴费信息
	 */
	@Override
	public PayManagement queryById(int id) {
		if (id != 0) {
			PayManagement payManagement = pmd.find(id);

			return payManagement;
		} else {

			return null;
		}
	}

	/***
	 * @param
	 *            billNo
	 * @return PayManagement 根据缴费编号查找缴费
	 */
	@Override
	public PayManagement queryByBillNo(String billNo) {
		if (billNo != null) {
			PayManagement payManagement = pmd.querPayInformation(billNo);
			return payManagement;
		} else {
			return null;

		}
	}

	/***
	 * @param
	 *            args)
	 * @return boolean 批量删除缴费信息
	 */
	public boolean deletemore(Serializable[] args) {
		if (args != null && args.length != 0) {
			pmd.deleteByIds(args);
			return true;
		}
		return false;
	}

	/**
	 * 备用分页
	 */
	@Override
	public PageSupport<PayManagement> findPagination(int pageNo, int pageSize) {
		// TODO Auto-generated method stub
		return null;
	}

	/***
	 * 无返回值的删除缴费信息（根据ID）
	 */
	@Override
	public void deleteById(Integer id) {
		try {
			pmd.deleteById(id);
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

	@Override
	public PayManagement saveOrupdate(PayManagement t) {
		try {
			return pmd.saveOrUpdate(t);
		} catch (Exception e) {
			return null;
		}
	}

	@Override
	public List<PayManagement> findAllPayManagement() {
		
		return pmd.findAll();
	}

}
